using System;using System.Data;using System.Data.SqlClient;using System.Collections.Generic;namespace MyWeb.Data{	public class ImagesProductsDAL : SqlDataProvider	{		#region[ImagesProducts_GetById]		public List<ImagesProducts> ImagesProducts_GetById(string Id)		{			List<Data.ImagesProducts> list = new List<Data.ImagesProducts>();			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_GetById", GetConnection()))			{				Data.ImagesProducts obj = new Data.ImagesProducts();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ImagesProductsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[ImagesProducts_GetByTop]		public List<ImagesProducts> ImagesProducts_GetByTop(string Top, string Where, string Order)		{			List<Data.ImagesProducts> list = new List<Data.ImagesProducts>();			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_GetByTop", GetConnection()))			{				Data.ImagesProducts obj = new Data.ImagesProducts();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Top", Top));				dbCmd.Parameters.Add(new SqlParameter("@Where", Where));				dbCmd.Parameters.Add(new SqlParameter("@Order", Order));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ImagesProductsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[ImagesProducts_GetByAll]		public List<ImagesProducts> ImagesProducts_GetByAll()		{			List<Data.ImagesProducts> list = new List<Data.ImagesProducts>();			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_GetByAll", GetConnection()))			{				Data.ImagesProducts obj = new Data.ImagesProducts();				dbCmd.CommandType = CommandType.StoredProcedure;				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ImagesProductsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[ImagesProducts_Paging]		public List<ImagesProducts> ImagesProducts_Paging(string CurentPage, string PageSize)		{			List<Data.ImagesProducts> list = new List<Data.ImagesProducts>();			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_Paging", GetConnection()))			{				Data.ImagesProducts obj = new Data.ImagesProducts();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@CurentPage", CurentPage));				dbCmd.Parameters.Add(new SqlParameter("@PageSize", PageSize));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.ImagesProductsIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}		return list;		}		#endregion		#region[ImagesProducts_Insert]		public bool ImagesProducts_Insert(ImagesProducts data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_Insert", GetConnection()))			{
                dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@Name", data.Name));				dbCmd.Parameters.Add(new SqlParameter("@ProductsId", data.ProductsId == "" || data.ProductsId == "0" ? DBNull.Value : (object)data.ProductsId));				dbCmd.Parameters.Add(new SqlParameter("@Images", data.Images));
                dbCmd.Parameters.Add(new SqlParameter("@Ord", data.Ord));				dbCmd.Parameters.Add(new SqlParameter("@Active", data.Active));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("ImagesProducts");			return true;		}		#endregion		#region[ImagesProducts_Update]		public bool ImagesProducts_Update(ImagesProducts data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_Update", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;
                dbCmd.Parameters.Add(new SqlParameter("@Id", data.Id));
                dbCmd.Parameters.Add(new SqlParameter("@Name", data.Name));				dbCmd.Parameters.Add(new SqlParameter("@ProductsId", data.ProductsId == "" || data.ProductsId == "0" ? DBNull.Value : (object)data.ProductsId));				dbCmd.Parameters.Add(new SqlParameter("@Images", data.Images));
                dbCmd.Parameters.Add(new SqlParameter("@Ord", data.Ord));				dbCmd.Parameters.Add(new SqlParameter("@Active", data.Active));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("ImagesProducts");			return true;		}		#endregion		#region[ImagesProducts_Delete]		public bool ImagesProducts_Delete(string Id)		{			using (SqlCommand dbCmd = new SqlCommand("sp_ImagesProducts_Delete", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("ImagesProducts");			return true;		}		#endregion			}}